let id;
window.onload=function (){
    id = getQuery("id")
    findById();
}


function findById(){
    axios.get("/post/findById",{params:{id}}).then(resp=>{
        let info = resp.data;
        $("titleSpan").innerHTML=info.title;
        $("date").innerHTML=info.date;
        $("nameSpan").innerHTML=info.userBean.name;
        $("img").src=info.userBean.img;
        $("time").innerHTML=info.userBean.date;
        let  str = "";
        info.replyList.forEach(r=>{
            str += `<tr>
                        <td>${r.title}</td>
                        <td>${r.content}</td>
                        <td>${r.userBean.name}</td>
                        <td>${r.userBean.date}</td>
                        <td><img id="replyImg" src="${r.userBean.img}" width="30px" height="30px"></td>
                    </tr>`
        });
        $("data").innerHTML=str;
    })
}


function add() {
    axios.get("/reply/add",{
        params: {
            title:$("title").value,
            content:$("content").value,
            postId:id
        }
    }).then(resp=>{
        let info = resp.data;
        if(info == "ok"){
            $("errorDiv").innerHTML='添加成功';
        }
    })
}
function back() {
    location.href="/channel.html?id="+id;
}